package com.xiaobai.common.utils.tool;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class EncryptionUtil {

    /***
     * security认证当中的加密(Hash加密)
     */
    public static String encryption(String password) throws Exception {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.encode(password);
    }

    public static boolean checkPassword(String nowPassword, String encodedPassword) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.matches(nowPassword, encodedPassword);
    }

}
